package com.digitalart.futbol.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.digitalart.futbol.hibernate.ejb.Local;
import com.digitalart.futbol.hibernate.service.LocalService;

@Controller
@RequestMapping(value="/local")
public class LocalController {
	@Autowired
	private LocalService localServ;
	
	@RequestMapping(value = "/getById/{id}", method = RequestMethod.GET)
	public @ResponseBody Local getById(@PathVariable("id") int id) {
	
		Local local = localServ.retriveLocal(id);
		
		return local;
	}
	
	@RequestMapping(value = "/getAll", method = RequestMethod.GET)
	public @ResponseBody List<Local> getAll() {
	
		List<Local> locales = localServ.getAll();
		
		System.out.println(locales.size());
		
		return locales;
	}
}
